# -*- coding: utf8 -*-
'''
    1.4.4 Scipy的io模块、misc模块
'''

import os
from PIL import Image
from pylab import array
from scipy import io
from scipy.misc import imsave


data = {}
data['x'] = [1, 2, 'x']
io.savemat('test.mat', data)

# 加载mat文件
da = io.loadmat('test.mat')
print(da['x'])

infile = 'img/haizei.jpg'

# 读取图像到数组中
im = array(Image.open(infile).convert('L'))
outfile = os.path.splitext(infile)[0] + '1.4.4.jpg'

imsave(outfile, im)
